People in Japan have been recording cherry blossom timings antd climate data for over 1000 years, from 801 - 2015, in our data set below.
library(rethinking)
## Loading required package: rstan
## Loading required package: StanHeaders
## rstan (Version 2.21.2, GitRev: 2e1f913d3ca3)
## For execution on a local, multicore CPU with excess RAM we recommend calling
## options(mc.cores = parallel::detectCores()).
## To avoid recompilation of unchanged Stan programs, we recommend calling
## rstan_options(auto_write = TRUE)
##
## Attaching package: 'rstan'
## The following object is masked from 'package:tidyr':
##
## extract
## Loading required package: parallel
## rethinking (Version 2.11)
##
## Attaching package: 'rethinking'
## The following object is masked from 'package:purrr':
##
## map
## The following object is masked from 'package:stats':
##
## rstudent
data(cherry_blossoms)
d <- cherry_blossoms
precis(d)
| 1408.000000 |
| 104.540508 |
| 6.141886 |
| 7.185151 |
| 5.098941 |
|
| 350.8845964 |
| 6.4070362 |
| 0.6636479 |
| 0.9929206 |
| 0.8503496 |
|
| 867.77000 |
| 94.43000 |
| 5.15000 |
| 5.89765 |
| 3.78765 |
|
| 1948.23000 |
| 115.00000 |
| 7.29470 |
| 8.90235 |
| 6.37000 |
|
| ▇▇▇▇▇▇▇▇▇▇▇▇▁ |
| ▁▂▅▇▇▃▁▁ |
| ▁▃▅▇▃▂▁▁ |
| ▁▂▅▇▇▅▂▂▁▁▁▁▁▁▁ |
| ▁▁▁▁▁▁▁▃▅▇▃▂▁▁▁ |
|
d2 <- d[ complete.cases(d$doy) , ] # complete cases on doy
n <- nrow(d2)
d2$doy1 <- c( NA, d2$doy[-n] ) # add a lag
d2 <- d2[ -1, ] ## for model comparison later